package test.juc.executetask;

public class ExecuteTaskOrderlyTest1 {

    public static void main(String[] args) {
        executeTaskOrderly();
    }

    // 三个线程顺序执行任务
    public static void executeTaskOrderly(){
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("t1 start...");
            }
        });

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    t1.join();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t2 start...");
            }
        });

        Thread t3 = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    t2.join();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t3 start...");
            }
        });

        t3.start();
        t2.start();
        t1.start();
    }

}
